package com.realbrand.net.realbrandpay.adapter;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.realbrand.net.realbrandpay.R;
import com.realbrand.net.realbrandpay.bean.ScanBean;

import java.util.List;

/**
 * Created by Administrator on 2017/10/25.
 */

public class ShopcarListViewAdapter extends BaseAdapter {
    List<ScanBean> list;
    LayoutInflater inflater;

    public ShopcarListViewAdapter(List<ScanBean> list, LayoutInflater inflater) {
        this.list = list;
        this.inflater = inflater;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = inflater.inflate(R.layout.shopcarchileadapter_layout, parent, false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.tv_scan.setText(list.get(position).getScan());
        holder.tv_number.setText(position + 1 + "");
        return convertView;
    }

    class ViewHolder {
        private TextView tv_number;
        private TextView tv_scan;

        public ViewHolder(View view) {
            tv_number = (TextView) view.findViewById(R.id.shopcarchileadapter_tvNumber);
            tv_scan = (TextView) view.findViewById(R.id.shopcarchileadapter_tv);
        }
    }
}
